#pragma once
#include "SceneManager.h"
#include "Object2D.h"
#include "Image.h"
#include "ScreenText.h"
#include "RealTimeController.h"
#include "Randomizer.h"
#include "global_var.h"
#include "ScoreSystem.h"

#define _TURNFORCE_ 5.0f
#define _MAXFORCE_ 100.0f
#define _DECREMENTFORCE_ 20.0f
#define _TIMETOTURN_ 10.0f
#define _LOCKTIME_ 1.0f
#define _READYTIME_ 2.5f
#define _LOCKDELAY_ 1.5f
#define _ENDDELAY_ 3.0f

using namespace Pulpy;

class SaveTheDam : public Scene
{
private:
	float _Bar1;
	float _Bar2;
	float _TimeLeft;
	float _ReadyTime;
	TextureImage _SkyTexture;
	Object2D * _Sky;
	TextureImage _StageTexture;
	Object2D * _GameStage;
	TextureImage _WaterTexture;
	Object2D * _Water;
	Sprite * _WheelSprite;
	Object2D * _Wheel1;
	Object2D * _Wheel2;
	TextureImage _ChainTexture;
	TextureImage _FishTexture;
	TextureImage _P1Win;
	TextureImage _P2Win;
	Object2D * _Overlay;
	TextureImage _Ready;
	TextureImage _Go;
	TextureImage _Time;
	Sprite * _Numbers;
	Object2D * _TimeWord;
	Object2D * _TimeActual;
	float _LockDelay;
	Object2D * _Crack1;
	Object2D * _Crack2;
	Object2D * _Crack3;
	TextureImage _CrackTexture;
	Object2D * _Fish;
	Object2D * _OverflowWater;
	TextureImage _HowToPlay;
	bool _Wheel1Index;
	bool _Wheel1Lock;	
	bool _Wheel2Index;
	bool _Wheel2Lock;
	static bool const _AILockChance[];
	float _EndDelay;
	bool _Start;
	float _LockTime;
public:
	SaveTheDam();
	void draw();
	void update();
	void reset();
	void freeResource();
	void loadResource();
	void handleKeyboard(int key, int x, int y);
	void handleKeyboardUp(int key, int x, int y);
	void handleKeyboardSpecial(int key, int x, int y);
	void getMid(int &x, int &y);
	void handleMouseClick(int button, int state, int x, int y);
	void handleMouseMove(int x, int y);
};